import time #time/datetime处理时间和日期的模块
import datetime #对于时间处理函数也有

zs = time.time() #获取当前时间戳,从1900开始以秒做单位
print(zs)
time_tuple = time.localtime()    #获取当前时间的元组
print(time_tuple)

month = time_tuple.tm_mon   #获取月
day =time_tuple.tm_mday     #获取天
weekday = time_tuple.tm_wday   #获取星期几
print(month,day,weekday)
tupl=time.localtime(1710944470)  #将时间戳转换为元组
print(tupl)
time1 = time.mktime(tupl)   #把时间元组转换为时间戳
print(time1)
strTime = time.strftime("%Y-%m-%d %H:%M:%S",tupl)#时间元组转换为字符串
print(strTime)
tup2=time.strptime("2019-09-01 22:29:35",'%Y-$m-%d %H:%M:%S')   #字符串转换为时间元组
print(tup2)
# day = 0
# ruiYear = 0
# notRuiYear = 0
# for year in range(1900,2021):
#     #print(year)
#     if (year%4 ==0 and year%100!=0) or year %400==0:
#         print(year,"闰年")
#         ruiYear=ruiYear+1
#     else:
#         print(year,"不是闰年")
#         notRuiYear=notRuiYear+1
# print(f"闰年：{ruiYear}次")
# print(f"不是闰年：{notRuiYear}")
#
# #求2021年年初到4月21号的天数（包含当天）
# for month in range(1,5):
#     if month in(1,3):
#         day= day+30
#     elif month==2:
#         day +=28
#     else:
#         day = day+21
# day =day+ruiYear*366+notRuiYear*365
# print(f"从1900到2021年4月21共{day}天")
#
